package com.dd.probe.web.controller;

import com.dd.probe.common.pojo.param.SSHProbeConfigParam;
import com.dd.probe.web.service.internalApi.ConfigService;
import com.jcraft.jsch.ConfigRepository;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @Author liuxianmeng
 * @CreateTime 2024/12/22 13:13
 * @Description 提供对探针的配置服务
 */
@Slf4j
@RestController
@ApiModel("提供对探针的配置服务")
@RequiredArgsConstructor
@RequestMapping("/config")
public class ConfigController {

    private final ConfigService configService;

    @PostMapping("/SSH")
    @ApiOperation("配置探针的SSH信息 返回的布尔值表示配置成功与否")
    public ResponseEntity ssh(@ApiParam("探针SHH信息配置：只包含用户名、密码两个属性") @RequestBody SSHProbeConfigParam param) {
        return ResponseEntity.ok().body(configService.configSSH(param));
    }

    @PostMapping("/networkTargetInterface/{interfaceName}")
    @ApiOperation("配置要监控的目标网络接口[eth0|ens33]")
    public ResponseEntity ssh(@ApiParam("要监控的目标网络接口名[eth0|ens33]") @PathVariable("interfaceName") String interfaceName) {
        return ResponseEntity.ok().body(configService.configNetInterface(interfaceName));
    }
}
